﻿#define _CRT_SECURE_NO_WARNINGS 1
#include <algorithm>
#include <ios>
#include <iostream>
#include <unordered_map>
#include <vector>
using namespace std;

int main() {
    int n, l, r;
    cin >> n >> l >> r;
    vector<long long> arr(n);
    for (int i = 0; i < n; i++) cin >> arr[i];
    sort(arr.begin(), arr.end());

    int left = 0, right = 1;
    long long sum = 0;
    while (right < n)
    {
        if (left<right && arr[right] - arr[left]>r)
        {
            while (left<right && arr[right] - arr[left]>r)
            {
                left++;
            }
        }

        if (arr[right] - arr[left] >= l && arr[right] - arr[left] <= r)
        {
            int tmp = right - 1;
            while (tmp > left)
            {
                if (arr[right] - arr[tmp] >= l && arr[right] - arr[tmp] <= r) break;
                tmp--;
            }
            sum += (tmp - left + 1);
        }
        right++;
    }
    cout << sum;
    return 0;
}

// 64 位输出请用 printf("%lld")
//1 1 1
//1 0 0
//1 0 0
//1 0 0